import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
// import 'package:flutter_swiper/flutter_swiper.dart';

class SwiperExample extends StatefulWidget {
  final List  _images ;

 // CompanyInc(this._CompanyInc);
  //SwiperExample({Key key}) : super(key: key);
  SwiperExample(this._images);
  

  @override
  _SwiperExampleState createState() => _SwiperExampleState();
}

class _SwiperExampleState extends State<SwiperExample> {
  //  List<String> _images = [
  //   'https://img1.baidu.com/it/u=2336137416,3593454803&fm=26&fmt=auto&gp=0.jpg',
  //   'https://img1.baidu.com/it/u=251674983,1047412732&fm=26&fmt=auto&gp=0.jpg',
  //   'https://img1.baidu.com/it/u=1020384080,2889778571&fm=26&fmt=auto&gp=0.jpg'
  // ];

 Widget _swiperBuilder(BuildContext context, int index) {
  // print(this.widget._images[0]);

    return (Image.network(
      //"http://via.placeholder.com/350x150",
      //"https://img1.baidu.com/it/u=2336137416,3593454803&fm=26&fmt=auto&gp=0.jpg",
      this.widget._images[index],
      fit: BoxFit.fill,
    ));
  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // appBar: AppBar(
      //   title: Text("Swiper插件的使用"),
      // ),
      body: Container(
       
          width: MediaQuery.of(context).size.width,
          height: 250.0,
          child: Swiper(
            itemBuilder: _swiperBuilder,
            itemCount: this.widget._images.length,
            //设置 new SwiperPagination() 展示默认分页指示器
            pagination: new SwiperPagination(
              alignment	:Alignment.bottomRight, //控制分页指示器的位置
                builder: DotSwiperPaginationBuilder(
              color: Colors.black54,
              activeColor: Colors.white,
            )),
            //设置 new SwiperControl() 展示默认分页按钮
            //control: new SwiperControl(),
            scrollDirection: Axis.horizontal, //滚动方向，设置为Axis.vertical如果需要垂直滚动
            autoplay: true, //自动播放开关.
            onTap: (index) => print('点击了第$index个'),
          )),
    );
  }
}
